<?php
class testController extends CController {
	private $_project = null;
	public function filters() {
		return array (
			
			'accessControl', 
			'projectContext + index' 
		);
	}
	
	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules() {
		return array ();
	}
	function actionIndex() {
		echo "aa";
	}
	protected function loadProject($project_id) {
		//if the project property is null, create it based on input id
		if ($this->_project === null) {
			$admin_model = new Admin ( );
			$this->_project = $admin_model->findbyPk ( $project_id );
			if ($this->_project === null) {
				throw new CHttpException ( 404, '：该网页不存在' );
			}
		}
		return $this->_project;
	}
	
	public function filterProjectContext($filterChain) {
		$projectId = null;
		if (isset ( $_GET ['id'] ))
			$projectId = $_GET ['id'];
		else if (isset ( $_POST ['id'] ))
			$projectId = $_POST ['id'];
		$this->loadProject ( $projectId );
		$filterChain->run ();
	}
}
?>